package com.yn.pet.bus.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum DeviceStatusEnum {
    // 运动状态，code 对应 1
    MOVING(1, "运动"),
    // 静止状态，code 对应 2
    STATIC(2, "静止"), 
    // 离线状态，code 对应 3
    OFFLINE(3, "离线"); 

    private Integer code;
    private String name;

    public static DeviceStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DeviceStatusEnum statusEnum : DeviceStatusEnum.values()) {
            if (statusEnum.getCode().equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }
}